package com.huakang.service.impl;

import com.huakang.entity.Seeadoctor;
import com.huakang.entity.SeeadoctorExample;
import com.huakang.mapper.SeeadoctorMapper;
import com.huakang.service.SeeadoctorService;
import com.huakang.utils.SeeadoctorVo;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @Author{一只小呆瓜}
 * @Date2025/1/11 13:28
 */
@Service
@Transactional
public class SeeadoctorServiceImpl implements SeeadoctorService {
    @Autowired
    private SeeadoctorMapper seeadoctorMapper;

    @Override
    public List<SeeadoctorVo> findAll() {
        return seeadoctorMapper.findNameByPid();
    }

    @Override
    public List<SeeadoctorVo> findByName(String input) {
        return seeadoctorMapper.findByName(input);
    }

    @Override
    public List<SeeadoctorVo> findByPid(Integer sid) {

        return seeadoctorMapper.findById(sid);
    }

    @Override
    public boolean visit(Seeadoctor seeadoctor) {
        seeadoctor.setDate(new Date());
        return  seeadoctorMapper.updateByPrimaryKeySelective(seeadoctor)>0?true:false;
    }

    

    @Override
    public List<SeeadoctorVo> getInhosp() {
        return seeadoctorMapper.selectInhosp();
    }

    @Override
    public List<SeeadoctorVo> getSearch(String search) {
        return seeadoctorMapper.selectSearch(search);
    }

    @Override
    public boolean updateInhosp(Integer sid) {
        Seeadoctor seeadoctor = seeadoctorMapper.selectByPrimaryKey(sid);
        seeadoctor.setInhosp("已住院");
        int i = seeadoctorMapper.updateByPrimaryKeySelective(seeadoctor);
        return i>0?true:false;
    }

    @Override
    public List<Seeadoctor> findPidOne(Integer pid) {
        return seeadoctorMapper.findByidOne(pid);
    }

    @Override
    public boolean update(Seeadoctor seeadoctor) {
        return seeadoctorMapper.updateByPrimaryKeySelective(seeadoctor)>0?true: false;
    }

    @Override
    public boolean delete(Integer sid) {
        return seeadoctorMapper.deleteByPrimaryKey(sid)>0?true:false;
    }

    @Override
    public List<SeeadoctorVo> findByzhenduan(String input) {
        return  seeadoctorMapper.findByzhenduan(input);
    }


}
